/*
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2024-12-08     Tian Yiqing  the first version
 */

#ifndef __DRV_PULSE_ENCODER__
#define __DRV_PULSE_ENCODER__

#include <rtthread.h>
#include <rthw.h>
#include <rtdevice.h>
#include <board.h>

#ifdef __cplusplus
extern "C" {
#endif

#define MAX_CHN_COUNT 2

struct gd32_encoder_chn_data
{
    rcu_periph_enum chn_clk;
    uint32_t chn_port;
    uint32_t chn_af;               
    uint32_t chn_pin;
};

struct gd32_pulse_encoder
{
    char *name;
    uint32_t tim_periph;
    rcu_periph_enum tim_rcu;
    IRQn_Type tim_irqn;
    int32_t over_under_flowcount;
    struct gd32_encoder_chn_data chn_data[MAX_CHN_COUNT];
    struct rt_pulse_encoder_device pulse_encoder;    
};

#ifdef __cplusplus
}
#endif

#endif /* __DRV_PULSE_ENCODER__ */
